package cn.edu.swufe.surverpark.listener;


import javax.annotation.Resource;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import cn.edu.swufe.surverpark.struts2.service.LogService;
import cn.edu.swufe.surverpark.util.LogUtil;

/**
 * @author 陈龙 E-mail:529914446@qq.com
 * @version创建时间:2015年5月7日上午2:09:04 初始化权限监听器,在spring初始化完成后立即调用
 */
@Component
@SuppressWarnings("rawtypes")
public class InitLogTablesListener implements ApplicationListener {

	@Resource
	private LogService ls;

	@Override
	public void onApplicationEvent(ApplicationEvent arg0) {
		if (arg0 instanceof ContextRefreshedEvent) {
			String tableName = LogUtil.generateLogTableName(0);
			ls.createLogTable(tableName);
			tableName = LogUtil.generateLogTableName(1);
			ls.createLogTable(tableName);
			tableName = LogUtil.generateLogTableName(2);
			ls.createLogTable(tableName);
		}

	}
	
}
